package com.jianzhile.jobs.base;

import android.content.Context;
import android.widget.BaseAdapter;

import java.util.List;

public abstract class MBaseAdapter<T, AbsListView> extends BaseAdapter {
	public Context context;
	public List<T> list;
	public AbsListView view;// ListView,GridView

	public MBaseAdapter(Context context, List<T> list, AbsListView view) {
		this.context = context;
		this.list = list;
		this.view = view;
		((android.widget.AbsListView) view).setAdapter(this);
	}

	public MBaseAdapter(Context context, List<T> list) {
		this.context = context;
		this.list = list;
	}

	public void setList(List<T> list) {
		this.list = list;
	}

	@Override
	public int getCount() {
		return list.size();
	}

	@Override
	public T getItem(int position) {
		return list.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	public void clear() {
		if (list != null) {
			list.clear();
			notifyDataSetChanged();
		}
	}
}
